package com.qeegoo.b2bautozityp.moudle.good.viewmodel.category;

import android.app.Activity;
import android.content.Intent;
import android.databinding.ObservableField;
import android.text.Html;

import com.kelin.mvvmlight.command.ReplyCommand;
import com.qeegoo.b2bautozityp.moudle.good.model.GoodsCategoryBean;

import base.lib.util.ActivityManager;

/**
 * 王少岩 在 2017/9/21 创建了它
 */

public class GoodsCategoryKeyWordViewModel {
    private GoodsCategoryBean mBean;
    public ObservableField<CharSequence> name = new ObservableField<>();
    public ReplyCommand clickCommand = new ReplyCommand(()->{
        Intent data = new Intent();
        data.putExtra("label", "绑定分类");
        data.putExtra("code", mBean.code);
        data.putExtra("name", mBean.name);
        ActivityManager.getActivity().setResult(Activity.RESULT_OK, data);
        ActivityManager.getActivity().finish();
    });

    public GoodsCategoryKeyWordViewModel(GoodsCategoryBean bean, String keyWords) {
        mBean = bean;
        this.name.set(Html.fromHtml(bean.name.replace(keyWords, "<font color='#ff6b25'>" + keyWords + "</font>")));
    }
}
